<template>
	<view class="delete-account-page">
		<!-- 导航栏 -->
		<view class="nav-bar">
			<view class="back-btn" @click="goBack">
				<text class="back-text">返回</text>
			</view>
			<view class="title">注销删除账号</view>
			<view class="right-icon">
				<image src="/static/personalCenter/details.png" mode="aspectFill"></image>
			</view>
		</view>

		<!-- 注销说明 -->
		<view class="content-section">
			<view class="warning-box">
				<view class="warning-title">⚠️ 重要提醒</view>
				<view class="warning-text">
					账号注销后将无法恢复，请谨慎操作！
				</view>
			</view>
			
			<view class="info-section">
				<view class="section-title">注销须知</view>
				<view class="info-list">
					<view class="info-item">
						<text class="item-dot">•</text>
						<text class="item-text">注销后账号信息将被永久删除</text>
					</view>
					<view class="info-item">
						<text class="item-dot">•</text>
						<text class="item-text">未完成的订单将被取消</text>
					</view>
					<view class="info-item">
						<text class="item-dot">•</text>
						<text class="item-text">账户余额将无法提现</text>
					</view>
					<view class="info-item">
						<text class="item-dot">•</text>
						<text class="item-text">历史记录将被清空</text>
					</view>
					<view class="info-item">
						<text class="item-dot">•</text>
						<text class="item-text">注销后无法重新注册相同手机号</text>
					</view>
				</view>
			</view>
			
			<view class="form-section">
				<view class="form-title">注销原因</view>
				<view class="reason-list">
					<view 
						class="reason-item" 
						v-for="(reason, index) in reasons" 
						:key="index"
						:class="{ active: selectedReason === index }"
						@click="selectReason(index)"
					>
						<text class="reason-text">{{ reason }}</text>
						<view class="check-icon" v-if="selectedReason === index">✓</view>
					</view>
				</view>
				
				<view class="input-section">
					<view class="input-title">其他原因（可选）</view>
					<textarea 
						class="reason-input" 
						placeholder="请输入其他注销原因..."
						v-model="otherReason"
						maxlength="200"
					></textarea>
					<view class="char-count">{{ otherReason.length }}/200</view>
				</view>
			</view>
		</view>

		<!-- 底部按钮 -->
		<view class="bottom-actions">
			<view class="action-buttons">
				<view class="cancel-btn" @click="goBack">
					<text>取消</text>
				</view>
				<view class="confirm-btn" @click="confirmDelete">
					<text>确认注销</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			selectedReason: -1,
			otherReason: '',
			reasons: [
				'不再使用该平台',
				'注册了新的账号',
				'个人信息安全问题',
				'平台功能不满足需求',
				'客服服务不满意',
				'其他原因'
			]
		}
	},
	methods: {
		// 返回上一页
		goBack() {
			uni.navigateBack()
		},
		
		// 选择注销原因
		selectReason(index) {
			this.selectedReason = index
		},
		
		// 确认注销
		confirmDelete() {
			if (this.selectedReason === -1) {
				uni.showToast({
					title: '请选择注销原因',
					icon: 'none'
				})
				return
			}
			
			uni.showModal({
				title: '确认注销',
				content: '注销后账号将无法恢复，确定要注销吗？',
				confirmText: '确认注销',
				confirmColor: '#ff4757',
				success: (res) => {
					if (res.confirm) {
						this.submitDeleteRequest()
					}
				}
			})
		},
		
		// 提交注销请求
		submitDeleteRequest() {
			const reason = this.selectedReason === 5 ? this.otherReason : this.reasons[this.selectedReason]
			
			uni.showLoading({
				title: '正在处理...'
			})
			
			// 模拟API请求
			setTimeout(() => {
				uni.hideLoading()
				uni.showToast({
					title: '注销申请已提交',
					icon: 'success'
				})
				
				// 清除本地存储
				uni.removeStorageSync('userInfo')
				uni.removeStorageSync('token')
				uni.removeStorageSync('is_auth')
				
				// 返回登录页
				setTimeout(() => {
					uni.reLaunch({
						url: '/pages/login/index'
					})
				}, 1500)
			}, 2000)
		}
	}
}
</script>

<style lang="scss" scoped>
.delete-account-page {
	min-height: 100vh;
	background-color: #f5f5f5;
	padding-bottom: 120rpx;
}

.nav-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20rpx 30rpx;
	background-color: #fff;
	border-bottom: 1rpx solid #eee;
}

.back-btn {
	display: flex;
	align-items: center;
}

.back-text {
	color: #ff7937;
	font-size: 28rpx;
}

.title {
	font-size: 36rpx;
	font-weight: bold;
	color: #333;
}

.right-icon image {
	width: 32rpx;
	height: 32rpx;
}

.content-section {
	padding: 20rpx;
}

.warning-box {
	background-color: #fff3cd;
	border: 1rpx solid #ffeaa7;
	border-radius: 16rpx;
	padding: 30rpx;
	margin-bottom: 30rpx;
}

.warning-title {
	font-size: 32rpx;
	font-weight: bold;
	color: #856404;
	margin-bottom: 15rpx;
}

.warning-text {
	font-size: 28rpx;
	color: #856404;
}

.info-section {
	background-color: #fff;
	border-radius: 16rpx;
	padding: 30rpx;
	margin-bottom: 30rpx;
}

.section-title {
	font-size: 32rpx;
	font-weight: bold;
	color: #333;
	margin-bottom: 20rpx;
}

.info-list {
	.info-item {
		display: flex;
		align-items: flex-start;
		margin-bottom: 15rpx;
		
		&:last-child {
			margin-bottom: 0;
		}
	}
	
	.item-dot {
		font-size: 28rpx;
		color: #ff4757;
		margin-right: 10rpx;
		margin-top: 2rpx;
	}
	
	.item-text {
		font-size: 28rpx;
		color: #666;
		line-height: 1.5;
	}
}

.form-section {
	background-color: #fff;
	border-radius: 16rpx;
	padding: 30rpx;
}

.form-title {
	font-size: 32rpx;
	font-weight: bold;
	color: #333;
	margin-bottom: 20rpx;
}

.reason-list {
	.reason-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 25rpx 20rpx;
		border: 2rpx solid #eee;
		border-radius: 12rpx;
		margin-bottom: 15rpx;
		transition: all 0.3s;
		
		&.active {
			border-color: #ff7937;
			background-color: #fff5f0;
		}
	}
	
	.reason-text {
		font-size: 28rpx;
		color: #333;
	}
	
	.check-icon {
		font-size: 32rpx;
		color: #ff7937;
		font-weight: bold;
	}
}

.input-section {
	margin-top: 30rpx;
}

.input-title {
	font-size: 28rpx;
	color: #333;
	margin-bottom: 15rpx;
}

.reason-input {
	width: 100%;
	height: 120rpx;
	border: 2rpx solid #eee;
	border-radius: 12rpx;
	padding: 20rpx;
	font-size: 28rpx;
	color: #333;
	background-color: #f9f9f9;
}

.char-count {
	text-align: right;
	font-size: 24rpx;
	color: #999;
	margin-top: 10rpx;
}

.bottom-actions {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background-color: #fff;
	padding: 20rpx 30rpx;
	border-top: 1rpx solid #eee;
}

.action-buttons {
	display: flex;
	gap: 20rpx;
}

.cancel-btn, .confirm-btn {
	flex: 1;
	height: 80rpx;
	border-radius: 12rpx;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cancel-btn {
	background-color: #f5f5f5;
	
	text {
		font-size: 32rpx;
		color: #666;
	}
}

.confirm-btn {
	background-color: #ff4757;
	
	text {
		font-size: 32rpx;
		color: #fff;
	}
}
</style> 